package pl.edu.agh.nn.layer;

import java.util.ArrayList;
import java.util.List;

import pl.edu.agh.nn.conf.InvalidNetworkConfigurationException;
import pl.edu.agh.nn.neuron.AbstractNeuron;
import pl.edu.agh.nn.neuron.InputNeuron;

public class InputLayer implements ILayer {

	private int neuronCount;
	protected List<InputNeuron> neurons;

	public InputLayer() {

	}

	@Override
	public void configure() throws InvalidNetworkConfigurationException {
		if (((neurons == null) || neurons.isEmpty())) {
			if (getNeuronCount() < 1) {
				throw new InvalidNetworkConfigurationException();
			} else {
				neurons = new ArrayList<InputNeuron>();
				for (int i = 0; i < getNeuronCount(); i++) {
					InputNeuron neuron = new InputNeuron();
					neurons.add(neuron);
				}
			}
		}
	}

	public int getNeuronCount() {
		return neuronCount;
	}

	@Override
	public List<? extends AbstractNeuron<?>> getNeurons() {
		return neurons;
	}

	@Override
	public ILayer getPreviousLayer() {
		// N/A
		return null;
	}

	public void setNeuronCount(int neuronCount) {
		this.neuronCount = neuronCount;
	}

	public void setNeurons(List<InputNeuron> neurons) {
		this.neurons = neurons;
	}

	@Override
	public void setPreviousLayer(ILayer layer) {
		// N/A
	}
}
